// load our libraries
var S = require('./simpleNodebe.js');
var D = require("./argDeserializer.js");

// load app libraries
var express = require('express');

var app = express();
app.use(express.bodyParser());

var simpleNodebe = new S.SimpleNodebe();

app.all('/', function(req, res) {
    var params = D.deserializeMap(req.body);
    console.log(params);

    var action = params.Action;
    simpleNodebe[action](params, function(err, data) {
        res.status(err ? 500 : 200);
        res.end(err ? err : data);
    });
});

var port = process.argv[2];
app.listen(port);
